Skip to content

feat(mcp): add rank-tracking keyword write tools - #196

Open
Despiram wants to merge 1 commit into
every-app:mainfrom
Despiram:feat/mcp-rank-tracking-write
Open

feat(mcp): add rank-tracking keyword write tools#196
Despiram wants to merge 1 commit into
every-app:mainfrom
Despiram:feat/mcp-rank-tracking-write

Conversation

@Despiram

@Despiram Despiram commented Aug 7, 2026

Copy link
Copy Markdown

Motivation

Self-hosted agents can already read the rank tracker over MCP (get_rank_tracker), but they cannot manage its watchlist — adding or pruning tracked keywords still requires the dashboard. This enables agent-driven keyword management: an agent doing keyword research over MCP can now promote its findings straight into the tracker (and clean up stale ones) without a human round-trip.

What this adds

  • add_rank_tracking_keywords — adds keywords (1–100) to a project's rank tracker. Reports added, already-tracked (duplicate), and cap-skipped keywords. Uses no credits and triggers no check; positions appear on the next scheduled or dashboard-triggered check.
  • remove_rank_tracking_keywords — removes keywords from the watchlist, matching case-insensitively after trimming (the stored normal form). Unmatched keywords are reported rather than erroring. Marked destructiveHint: true.
  • Both tools accept an optional trackerId and resolve the tracker automatically when the project has exactly one; with several trackers, the error lists them so the agent can pick.
  • Both are thin wrappers over the existing RankTrackingService.addKeywords / removeKeywords — no duplicated business logic — and are scoped through withMcpProjectAuth like the other project tools.
  • Registered in src/server/mcp/server.ts and listed on the AI/MCP settings page (AvailableTools).

Intentionally left out: auto-triggering a rank check after adding (the server-function path does this for the dashboard). An MCP write should not silently spend credits; the tool says so in its output text instead.

How it was tested

  • New src/server/mcp/tools/rank-tracking-write-tools.test.ts (7 tests) following the existing tool-test pattern: service pass-through + duplicate reporting, single-tracker resolution, multi-tracker/unknown-tracker rejection before any write, cap-skip reporting, keyword→ID mapping on remove, and no service call when nothing matches.
  • Full suite: pnpm test — 95 files, 775 tests, all passing.
  • knip, tsc --noEmit (main + badseo), and oxlint . --type-aware all clean; new/touched files formatted with Prettier. (Repo-wide prettier --check fails on this Windows checkout due to CRLF conversion, unrelated to this change.)

🤖 Generated with Claude Code

Add add_rank_tracking_keywords and remove_rank_tracking_keywords MCP
tools so agents can manage a rank tracker's watchlist, not just read it
via get_rank_tracker.

Both tools call the existing RankTrackingService (no duplicated
business logic), scope access through withMcpProjectAuth, and resolve
the tracker automatically when the project has exactly one. Adding
reports added/duplicate/limit-skipped keywords and triggers no check
(no credits spent); removing matches keywords case-insensitively and
reports unmatched ones. Tools are listed on the AI/MCP settings page.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant